package com.cj.mobile.iabp.mvp.model;

import com.cj.mobile.iabp.app.global.AccountManager;
import com.cj.mobile.iabp.mvp.contract.AddRemoveConcernInfoContract;
import com.cj.mobile.iabp.mvp.model.api.service.AccountService;
import com.jess.arms.cj.ApiOperator;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 2025/09/30 18:01
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
public class AddRemoveConcernInfoModel extends BaseModel implements AddRemoveConcernInfoContract.Model {
    @Inject
    ApiOperator apiOperator;                                                                        // 数据转换

    @Inject
    AccountManager mAccountManager;

    @Inject
    public AddRemoveConcernInfoModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.apiOperator = null;
        this.mAccountManager = null;
    }

    @Override
    public Observable<Integer> updateRemove(String per, String focuse, String id, String patienId, String ast, String alt, String cr, String egfr, String myo, String clac,
                                            String ga, String leftSize, String leftScore, String nirsLeft, String nirsRight, List<String> lessL,
                                            List<String> lessR) {
        Map<String, Object> params = new HashMap<>();
        params.put("per", per);
        params.put("focuse", focuse);
        params.put("id", id);
        params.put("patienId", patienId);
        params.put("ast", ast);
        params.put("alt", alt);
        params.put("cr", cr);
        params.put("egfr", egfr);
        params.put("myo", myo);
        params.put("clac", clac);
        params.put("ga", ga);
        params.put("leftSize", leftSize);
        params.put("leftScore", leftScore);
        params.put("nirsLeft", nirsLeft);
        params.put("nirsRight", nirsRight);
        params.put("lessL", lessL);
        params.put("lessR", lessR);

        return apiOperator.chain(params, request -> mRepositoryManager.obtainRetrofitService(AccountService.class).updateRemove(mAccountManager.getToken(), request));
    }
}